var fs = require('fs')
    , events = require('core/events');

exports.home = function(req, res){
  res.render('event/home', {title: 'Home'});
};

exports.create = function(req, res){
  res.render('event/create', {title: 'Create'});
};

exports.createTrack = function(req, res){
    var name = req.params.name;
    var event = events.get(name);
    res.render('event/create-track', { event: event, title: 'Create' });
};

exports.post = function (req, res) {
    var name = req.body.name;
    if (events.get(name) != undefined) res.redirect('event/create');
    events.add(name);
    res.redirect('event/create/' + name);
};

exports.get = function (req, res) {
    var name = req.params.name;
    var event = events.get(name);
    res.render('event/' + name, { event: event, title: 'Event' });
};